﻿using FileToVideo.Class;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileToVideo.AddFunc
{
    /// <summary>
    /// 数据帧追加方法
    /// </summary>
    public static class DataFrameAdd
    {
        /// <summary>
        /// 使用 Newtonsoft.Json 从 string 中读取数据
        /// </summary>
        /// <param name="dataFrame"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public static DataFrame FromString(this DataFrame dataFrame, string input)
        {
            var settings = new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.All // 保留类型信息
            };

            dataFrame = JsonConvert.DeserializeObject<DataFrame>(input, settings);
            return dataFrame;
        }
    }
}
